﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace PCL
{
    /// <summary>
    /// GUI接口
    /// </summary>
    /// <remarks></remarks>
    public interface IView
    {
        void DisplayPlayCard();

        void DisplaySelectCard();

        void Update();
    }

    /// <summary>
    /// 操作接口
    /// </summary>
    public interface IControl
    {
        IModel IModel
        {
            get;
            set;
        }

        IView IView
        {
            get;
            set;
        }

        void RequestSelectCard(int index);

        void RequestPlayCard();
    }

    /// <summary>
    /// 模型接口
    /// </summary>
    public interface IModel
    {
        int ID
        {
            get;
            set;
        }

        string Name
        {
            get;
            set;
        }

        CardType CardType
        {
            get;
            set;
        }

        void AddObserver(IView view);

        void RemoveObserver(IView view);

        void NotifyObserver();
    }

    public enum CardType
    {
        /// <summary>
        /// 角色卡
        /// </summary>
        RoleCard,
        /// <summary>
        /// 怪兽卡
        /// </summary>
        MonsterCard,
        /// <summary>
        /// 事件卡
        /// </summary>
        EventCard,
    }

    public class Card : IModel
    {
        public int ID
        {
            get
            {
                throw new NotImplementedException();
            }
            set
            {
                throw new NotImplementedException();
            }
        }

        public string Name
        {
            get
            {
                throw new NotImplementedException();
            }
            set
            {
                throw new NotImplementedException();
            }
        }

        public CardType CardType
        {
            get
            {
                throw new NotImplementedException();
            }
            set
            {
                throw new NotImplementedException();
            }
        }

        private IList<IView> observers;

        public void AddObserver(IView view)
        {
            observers.Add(view);
        }

        public void RemoveObserver(IView view)
        {
            observers.Remove(view);
        }

        public void NotifyObserver()
        {
            foreach (var item in observers)
            {
                item.Update();
            };
        }
    }
}
